//
//  FDBaseTableViewController.swift
//  WeiBoSwift
//
//  Created by Jacky Sun on 16/4/20.
//  Copyright © 2016年 syf. All rights reserved.
//

import UIKit

class FDBaseTableViewController: UITableViewController ,NotLoginDelegate {
    
    var  isLogin : Bool = UserAccount.isLogin()
        
    var  notLoginView : NotLoginView?
 
    //第一次加载的时候
    override func loadView() {
        isLogin ? super.loadView() : setNotLoginView()
    }

    
    private func  setNotLoginView() {
        notLoginView = NotLoginView()
        notLoginView?.delegate = self
        view = notLoginView!
        
       navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(FDBaseTableViewController.userRegisterClick))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(FDBaseTableViewController.userLoginingClick))
    }
    
    func userRegisterClick() {
        
         let account =  UserAccount.getUserAccount()
        print(account)

     }
    
    func userLoginingClick() {
        
        let vc = Oauth2ViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor(red: 242/255.0, green: 242/255.0, blue: 242/255.0, alpha: 1.0)
    }

}
